import { Select as AntdSelect } from 'antd';
import React from 'react';
import CloseIcon from './CloseIcon';

import type { SelectProps as AntdSelectProps } from 'antd';
import type { OptionProps, SelectValue } from 'antd/lib/select';
import type { OptGroupProps } from 'rc-select/lib/OptGroup';

export type SelectProps<VT = SelectValue> = AntdSelectProps<VT>;

function Select<VT extends SelectValue>(props: SelectProps<VT>) {
  const selectProps = {
    clearIcon: <CloseIcon isShowBg />,
    removeIcon: <CloseIcon />,
    ...props,
  };
  return <AntdSelect {...selectProps} />;
}

function Option(props: OptionProps) {
  return <AntdSelect.Option {...props} />;
}
function OptGroup(props: OptGroupProps) {
  return <AntdSelect.OptGroup {...props} />;
}
Select.Option = Option;
Select.OptGroup = OptGroup;
export { OptGroup, Option };

export default Select;
